4 * @covers ParserFactory
6 class ParserFactoryIntegrationTest
extends MediaWikiIntegrationTestCase
{
7 public function provideConstructorArguments() {
8 // Create a mock Config object that will satisfy ServiceOptions::__construct
9 $mockConfig = $this->createMock( 'Config' );
10 $mockConfig->method( 'has' )->willReturn( true );
11 $mockConfig->method( 'get' )->willReturn( 'I like otters.' );
14 [ 'the plural of platypus...' ],
15 $this->createMock( 'MagicWordFactory' ),
16 $this->createMock( 'Language' ),
18 $this->createMock( 'MediaWiki\Special\SpecialPageFactory' ),
20 $this->createMock( 'MediaWiki\Linker\LinkRendererFactory' ),
23 yield
'args_without_namespace_info' => [
26 yield
'args_with_namespace_info' => [
27 array_merge( $mocks, [ $this->createMock( 'NamespaceInfo' ) ] ),
32 * @dataProvider provideConstructorArguments
33 * @covers ParserFactory::__construct
35 public function testBackwardsCompatibleConstructorArguments( $args ) {
36 $this->hideDeprecated( 'ParserFactory::__construct with Config parameter' );
37 $factory = new ParserFactory( ...$args );
38 $parser = $factory->create();
40 // It is expected that these are not present on the parser.
44 foreach ( ( new ReflectionObject( $parser ) )->getProperties() as $prop ) {
45 $prop->setAccessible( true );
46 foreach ( $args as $idx => $mockTest ) {
47 if ( $prop->getValue( $parser ) === $mockTest ) {
53 $this->assertCount( 0, $args, 'Not all arguments to the ParserFactory constructor were ' .
54 'found in Parser member variables' );